﻿/*****************************************************************//**
 * @file    FITKGraphObjectAssemblyPoints.h
 * @brief   Graph object for assembly points( mesh ref-points ).
 *  
 * @author  ChengHaotian (yeguangbaozi@foxmail.com)
 * @date    2024-07-18
 *********************************************************************/

#ifndef __FITKGRAPHOBJECTASSEMBLYPOINTS_H__
#define __FITKGRAPHOBJECTASSEMBLYPOINTS_H__

#include "FITKGraphObject3D.h"

#include "FITKVTKGraphAdaptorAPI.h"

// Forward declaration
class vtkUnstructuredGrid;
class vtkPoints;

class FITKGraphActor;

namespace Interface
{
    class FITKAbaAssembly;
}

namespace Exchange
{
    /**
     * @brief   Graph object for assembly points( mesh ref-points ).
     * @author  ChengHaotian (yeguangbaozi@foxmail.com)
     * @date    2024-07-18
     */
    class FITKVTKGRAPHADAPTORAPI FITKGraphObjectAssemblyPoints : public FITKGraphObject3D
    {
        // Regist
        FITKGraphObjectRegist(FITKGraphObjectAssemblyPoints, FITKGraphObject3D);
        FITKCLASS(Exchange, FITKGraphObjectAssemblyPoints);

    public:
        /**
         * @brief   Constructor.
         * @param   caseData: The case data
         * @param   assemblyData: The assembly data object
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-18
         */
        FITKGraphObjectAssemblyPoints(AbaqusData::FITKDataCase* caseData, Interface::FITKAbaAssembly* assemblyData);

        /**
         * @brief   Destructor.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-18
         */
        virtual ~FITKGraphObjectAssemblyPoints();

        /**
         * @brief   Get the fixed sized bounds of this graph object.[override]
         * @param   The bounds size
         * @return  If the graph object has fixed sized bounds
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-18
         */
        bool getFixedBounds(double* bounds) override;

        /**
         * @brief   Set if the graph object can be picked.[override]
         * @param   isPickable: Pickable
         * @param   dim: The dimision of the pickable object( -1 means the whole graph object )[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-18
         */
        void setPickable(bool isPickable, int dim = -1) override;

        /**
         * @brief   Update the assembly points.[override]
         * @param   forceUpdate: Force update[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-18
         */
        void update(bool forceUpdate = false) override;

    private:
        /**
         * @brief   Constructor.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-18
         */
        FITKGraphObjectAssemblyPoints() = default;

        /**
         * @brief   Initialize the pointers.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-18
         */
        void init();

        /**
         * @brief   Clear the grid data for assembly points.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-18
         */
        void clearModelData();

        /**
         * @brief   Generate the poly data for the assembly points.
         * @param   assemblyData: The assembly data object
         * @return  Is OK
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-18
         */
        bool generatePolyData(Interface::FITKAbaAssembly* assemblyData);

        /**
         * @brief   Generate the graph actor with the assembly points.
         * @param   assemblyData: The assembly data object
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-18
         */
        void generateGraph();

    private:
        /**
         * @brief   The graph actor for poinst.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-18
         */
        FITKGraphActor* m_fActor{ nullptr };

        /**
         * @brief   The points grid data.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-18
         */
        vtkUnstructuredGrid* m_ugrid{ nullptr };

        /**
         * @brief   IThe points data.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2024-07-18
         */
        vtkPoints* m_points{ nullptr };

    };
}   // namespace Exchange

#endif // __FITKGRAPHOBJECTASSEMBLYPOINTS_H__
